
bussFormatter = function (value, row, index) {
    if (row.status== 1) {
        return [
            '<a href="javascript:void(0)" class="pass">删除</a>'
        ].join('');
    }
}



window.bussEvent = {

}

bussEvent = {
    'click .pass': function (e, value, row) {
        comment.showOperationTips("确定审核通过吗？", function () {
            $.post($().AbsUrlParse("/web/redpackage/deleteRedPackage"), {id: row.id}, function (data) {
                if (data.state == true) {
                    if (data.res.code == 40000) {
                        hint("操作成功,已经审核通过");
                        var table = $('#table');
                        table.bootstrapTable('refresh');
                    } else {
                        hint(data.res.msg);
                    }
                } else {
                    hint(data.msg);
                }

            });
        })
    },
};



var stateFormtter = function (value, row, index) {
    if (value == 1) {
        return '<span style="color:#00e765">已获取</span>';
    } else if (value == 2) {
        return '<span style="color:red">未获取</span>';
    }
}

//商家导出的功能
bindClick("#exportFinal", function () {
    var ids = getSelectedIds();
    if (ids == false) {
        return false;
    }
    $.post($().AbsUrlParse("/web/cash/busscashQueryExport"), {
        ids: ids
    }, function (data) {
        if (data.state == true) {
            if (data.res.code == 40000) {
                hint("导出成功");
                var a = document.createElement("a");
                a.href = $().AbsUrlParse("/excel/" + data.res.data);
                a.click();
            } else {
                hint(data.res.msg);
            }
        } else {
            hint(data.msg);
        }
    });
});


/**
 * 获取选择的提现信息
 * @returns {*}
 */
var getSelectedIds = function () {
    var table = $("#table");
    var selectedRows = table.bootstrapTable('getSelections');
    var selectedRowsLength = selectedRows.length;
    if (selectedRowsLength == 0) {
        hint("请选择数据");
        return false;
    }
    var ids = "";
    for (var i = 0; i < selectedRowsLength; i++) {
        ids += selectedRows[i].id + ",";
    }
    ids = ids.substring(0, ids.length - 1);

    return ids;
}


bindClick("#btnSearch", function () {

    var bussNameS = $("input[name=bussNameS]").val();
    var userNameS = $("input[name=userNameS]").val();
    var status = $("select[name=stateS]").val();


    var url = $().AbsUrlParse("/web/redpackage/redpackageQuery?bussName=" + bussNameS + "&userName="+userNameS+"&status=" + status);
    $("#table").bootstrapTable("refresh", {"url": url});
});


